﻿@{
    ViewBag.Title = "任务历史月表";
    Layout = "~/Views/Shared/_LayoutDualColumns.cshtml";
}
@using Global.Core.ExtensionMethod
@using Ducu.GLB.Global
@model Ducu.SRV.ViewModel.Task.HistoryMonthModel
@{
    var routeValue = ViewContext.RouteData.Values;

    object planId = routeValue["planId"];

    DateTime previousMonthEnd, nextMonth1st;
    int year = Convert.ToInt32(routeValue["year"]);
    int month = Convert.ToInt32(routeValue["month"]);

    previousMonthEnd = new DateTime(year, month, 1).AddDays(-1);

    if (month + 1 == 13)
    {
        nextMonth1st = new DateTime(year + 1, 1, 1);
    }
    else
    {
        nextMonth1st = new DateTime(year, month + 1, 1);
    }
}
@section PageHeader{
    <span class="glyphicon glyphicon-calendar" aria-hidden="true"></span><span class="after-glyphicon">@ViewBag.Title</span>
}
@Html.Action("_ShowItem", "Plan", new { id = planId })
<nav>
    <ul class="pager">
        @if (Model.PlanBegin <= previousMonthEnd)
        {
            <li class="previous">
                <a href="/Task/History/Month/@planId/@previousMonthEnd.Year/@previousMonthEnd.Month">&laquo;上月</a>
            </li>
        }
        <li style="padding:5px 14px; display:inline-block;">@(year)年@(month)月</li>
        @if (nextMonth1st <= Model.PlanEnd && nextMonth1st <= DateTime.Now)
        {
            <li class="next">
                <a href="/Task/History/Month/@planId/@nextMonth1st.Year/@nextMonth1st.Month">下月&raquo;</a>
            </li>
        }
    </ul>
</nav>
<table class="table table-striped" id="month">
    <tbody>
        <tr>
            <th>一</th>
            <th>二</th>
            <th>三</th>
            <th>四</th>
            <th>五</th>
            <th>六</th>
            <th>日</th>
        </tr>
        @for (int j = 0; j < Model.Items.Count / 7; j++)
        {
            <tr>
                @for (int i = 0; i < 7; i++)
                {
                    <td>@Html.Partial("Shared/_Day", Model.Items[j * 7 + i])</td>
                }
            </tr>
        }
    </tbody>
</table>
<script>
    $(document).ready(function () {
        $("#month .glyphicon[data-month!=@(month)]").attr("style", "color: lightgray");
    })
</script>
<a href="/Task/History/List/@planId" class="btn btn-primary btn-block">列表显示全部历史</a>
@Html.Partial("Shared/_HistoryContainer")
    @section RightPanel{
        <li>
            本页按月显示任务的完成情况。
        </li>
        <li>
            点击作业完成情况图标，可以显示其提交、拒收、验收等历史记录。
        </li>
        <li>
            点击<a href="/Task/History/List/@planId">列表显示全部历史</a>可以查看该目标下所有提交的任务完成情况。
        </li>
    }